<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/
get_config_keytable("config_user_Increase");
empty($do) && $do = 'list';
if ($do == 'list') {

    $auser_number = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."user");
	if ($auser_number>=GET_INC_CONFIG_INFO("auser_number"))
	{
	echo '您正在使用天生创想OA办公系统己经超出用户数，请联系开发商授权，软件购买:400-6767-169（<a href=http://www.515158.com/price.asp" style="color:red;" target="_blank">点击购买</a>';
	}else{
	include_once('template/add.php');
	}

} elseif ($do == 'save') {
	
	$savetype = getGP('savetype','P');
	$username = getGP('username','P');
	$password = md5(getGP('password','P'));
	$departmentid = getGP('departmentid','P');
	$name = getGP('name','P');
	$ischeck = getGP('ischeck','P');
	$positionid = getGP('positionid','P');
	$loginip = getGP('loginip','P');
	$groupid = getGP('groupid','P');
	$udate=get_date('y-m-d H:i:s',PHP_TIME);
	//主表信息
	$user = array(
		'username' => $username,
		'password' => $password,
		'groupid' => $groupid,
		'ischeck' => $ischeck,
		'departmentid' => $departmentid,
		'positionid' => $positionid,
		'loginip' => $loginip,
		'date' => $udate
	);
	//写入主表信息
	insert_db('user',$user);
	//返回主表ID
	$id=$db->insert_id();
	//基本信息
	$user_view = array(
		'name' => $name,
		'uid' => $id,
		'date' => $udate
	);
	//写入基本信息
	insert_db('user_view',$user_view);
	if($id!='')
	{
   $oalog = array(
		'uid' => $_USER->id,
		'content' => $username.get_inc_log(1).$name.get_inc_log(1).$positionid.get_inc_log(1).$loginip.get_inc_log(1).$ischeck.get_inc_log(1).$id.get_inc_log(1).$udate,
		'title' => '添加新用户'.$name,
		'startdate' => get_date('Y-m-d H:i:s',PHP_TIME),
		'contentid' => $id,
		'type' => '3'
	);
	insert_db('oalog',$oalog);
	}
    goto_page('admin.php?ac=index&fileurl=user');

}

?>